package com.chushouya.order.constants;

import com.general.framework.core.enums.IEnum;
import com.general.framework.core.lang.Strings;

import java.util.Objects;

public enum OrderPayStatusEnum implements IEnum<Integer> {

    //未支付
    UNPAID(0, "未支付"),
    //已付尾款
    BALANCE(20, "支付成功"),
    //已经扣款
    DEDUCTION(30, "已扣款"),
    //支付失败
    PAY_FAIL(60, "支付失败");

    private final Integer value;

    private final String desc;

    OrderPayStatusEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static String getDesc(Integer status) {
        for (OrderPayStatusEnum thisEnum : OrderPayStatusEnum.values()) {
            if (Objects.equals(thisEnum.value, status)) {
                return thisEnum.desc;
            }
        }
        return Strings.EMPTY;
    }

    @Override
    public Integer value() {
        return this.value;
    }

    @Override
    public String named() {
        return this.desc;
    }
}
